package br.com.scriptmanager.services.bso;

import java.util.ArrayList;
import java.util.List;

import br.com.scriptmanager.services.dbo.ScriptsFindAll;
import br.com.scriptmanager.services.factory.DBFactory;
import br.com.scriptmanager.services.factory.Filtros;

public class Script {
	
	public List<ScriptsFindAll> find10Scripts(){
		ArrayList<ScriptsFindAll> list = new ArrayList<ScriptsFindAll>();
		for( int i = 0; i < 10; i++ ){
			ScriptsFindAll s = new ScriptsFindAll();
			s.setIdScript(new Long(i));
			s.setIdTipoScript(1L);
			s.setDemanda("LMS-1374");
			s.setDescricao("Teste fabricio");
			s.setDtPD("12/12/2012");
			s.setQuestInfra("CPRO00001213");
			s.setScript("dasdasdasdasdasdasdasdas");
			s.setWeek("WK-12-12-30");
			
			list.add(s);
		}
		
		return list;
	}

	public ScriptsFindAll findScript(Long idTipoScript, String demanda){
		Filtros filtro = new Filtros();
		filtro.addString(ScriptsFindAll.DEMANDA, demanda);
		filtro.addObject(ScriptsFindAll.TIPO_SCRIPT, idTipoScript);
		
		DBFactory db = DBFactory.newInstance();
		ScriptsFindAll scriptsFindAll = (ScriptsFindAll)db.findOneResult(ScriptsFindAll.class, filtro);		
		return scriptsFindAll;
	}
	
}
